package cc.langk.web.mapper;

import cc.langk.web.entity.SysStaffVsRole;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.type.JdbcType;

public interface SysStaffVsRoleMapper {
    @Delete({
        "delete from sys_staff_vs_role",
        "where ROW_ID = #{rowId,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long rowId);

    @Insert({
        "insert into sys_staff_vs_role (EMP_ID, ROLE_ID)",
        "values (#{empId,jdbcType=BIGINT}, #{roleId,jdbcType=BIGINT})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="rowId", before=false, resultType=Long.class)
    int insert(SysStaffVsRole record);

    @Select({
        "select",
        "ROW_ID, EMP_ID, ROLE_ID",
        "from sys_staff_vs_role",
        "where ROW_ID = #{rowId,jdbcType=BIGINT}"
    })
    @Results({
        @Result(column="ROW_ID", property="rowId", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="EMP_ID", property="empId", jdbcType=JdbcType.BIGINT),
        @Result(column="ROLE_ID", property="roleId", jdbcType=JdbcType.BIGINT)
    })
    SysStaffVsRole selectByPrimaryKey(Long rowId);

    @Select({
        "select",
        "ROW_ID, EMP_ID, ROLE_ID",
        "from sys_staff_vs_role"
    })
    @Results({
        @Result(column="ROW_ID", property="rowId", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="EMP_ID", property="empId", jdbcType=JdbcType.BIGINT),
        @Result(column="ROLE_ID", property="roleId", jdbcType=JdbcType.BIGINT)
    })
    List<SysStaffVsRole> selectAll();

    @Update({
        "update sys_staff_vs_role",
        "set EMP_ID = #{empId,jdbcType=BIGINT},",
          "ROLE_ID = #{roleId,jdbcType=BIGINT}",
        "where ROW_ID = #{rowId,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(SysStaffVsRole record);
}